package com.morgan.basemodule.holder

import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView

/**
 *description：
 *<br>author：caowugao
 *<br>time：2021/2/26 0026 16:59
 */

fun <DATA, BINDING : ViewDataBinding> RecyclerView.ViewHolder.bindData(binding : BINDING, variableId : Int, value : DATA, needExecuteBinding : Boolean = false) {
    if (variableId != -1) {
        binding.setVariable(variableId, value)
        if (needExecuteBinding) {
            binding.executePendingBindings()
        }
    }
}